import request from '@/utils/request'

// 工作台 首页 待我处理
export function listMainPageMe(query) {
  return request({
    url: '/ec/flow/listMainPageMe',
    method: 'get',
    params: query
  })
}

// 生成模板合同
export function contractSignAutoAdd(data) {
  return request({
    url: '/ec/flow/autoAdd',
    method: 'post',
    data: data
  })
}

// 待我签署
export function listContractSignMine(query) {
  return request({
    url: '/ec/flow/listMe',
    method: 'get',
    params: query
  })
}
// 待我方签署
export function listContractSignOur(query) {
  return request({
    url: '/ec/flow/listOur',
    method: 'get',
    params: query
  })
}

// 根据员工id和公司id查询签署流程
export function selectContractSignFlowListByStaffIdAndCompanyId(query) {
  return request({
    url: '/ec/flow/selectContractSignFlowListByStaffIdAndCompanyId/'+query,
    method: 'get',
  })
}

//待他方签署
export function listContractSignOther(query) {
  return request({
    url: '/ec/flow/listOther',
    method: 'get',
    params: query
  })
}

//全部签署完成
export function listContractSignAllSuccess(query) {
  return request({
    url: '/ec/flow/listAllSuccess',
    method: 'get',
    params: query
  })
}

// 已撤销合同
export function listContractSignBack(query) {
  return request({
    url: '/ec/flow/listBack',
    method: 'get',
    params: query
  })
}

// 修改流程状态
export function updateContractSignFlowStatus(contractId,status) {
  return request({
    url: '/ec/flow/updateContractSignFlowStatus/'+contractId+'/'+status,
    method: 'put',
  })
}

// 单份签署合同
export function signOneContract(data) {
  return request({
    url: '/ec/flow/signOneContract',
    method: 'post',
    data: data
  })
}

// 签署合同 (人脸识别) 录制文件上传
export function signFace(data) {
  return request({
    url: '/ec/flow/signFace',
    method: 'post',
    data: data
  })
}

// 批量签署合同
export function batchSignContract(data) {
  return request({
    url: '/ec/flow/batchSignContract',
    method: 'post',
    data: data
  })
}

// 批量签署合同 取消当前合同
export function cancelOneSignContract(query) {
  return request({
    url: '/ec/flow/cancelOneSignContract',
    method: 'put',
    params: query
  })
}

// 根据批量勾选的签署流程生成 签署批量id
export function genBatchSignId(data) {
  return request({
    url: '/ec/flow/genBatchSignId',
    method: 'post',
    data: data
  })
}

// 根据 签署批量id 获取签署流程
export function getContractSignFlowByBatchSignId(batchSignId) {
  return request({
    url: '/ec/flow/getContractSignFlowByBatchSignId/'+batchSignId,
    method: 'get',
  })
}


// 抄送合同
export function listContractSignCopy(query) {
  return request({
    url: '/ec/copy/list',
    method: 'get',
    params: query
  })
}

// 临时分享合同
export function listContractSignShare(query) {
  return request({
    url: '/ec/flow/listShare',
    method: 'get',
    params: query
  })
}

// 根据合同id 查询 抄送合同
export function listContractSignCopyByContractId(id) {
  return request({
    url: '/ec/copy/list/' + id,
    method: 'get',
  })
}

// 删除抄送
export function delContractSignCopyById(id) {
  return request({
    url: '/ec/copy/' + id,
    method: 'delete',
  })
}


// 查询合同签署流程详细
export function getContractSignMine(id) {
  return request({
    url: '/ec/flow/' + id,
    method: 'get'
  })
}

// 查询合同签署流程详细 根据加密的rsa查询数据
export function getContractSignMineByRsa(id) {
  return request({
    url: '/ec/flow/rsa/' + id,
    method: 'get'
  })
}

// 新增合同签署流程
export function addContractSignMine(data) {
  return request({
    url: '/ec/flow',
    method: 'post',
    data: data
  })
}

// 修改合同签署流程
export function updateContractSignMine(data) {
  return request({
    url: '/ec/flow',
    method: 'put',
    data: data
  })
}

// 修改接收方信息 接收方信息填错等修改 联合修改控件数据
export function updateContractFlowRecive(data) {
  return request({
    url: '/ec/flow/updateContractFlowRecive',
    method: 'put',
    data: data
  })
}

// 修改合同签署流程 关联修改 主合同 常用修改一些 主子表 共同的状态
export function updateContractAndContractFlowByFlowId(data) {
  return request({
    url: '/ec/flow/updateContractAndContractFlowByFlowId',
    method: 'put',
    data: data
  })
}

// 修改【全部】合同签署流程 关联修改 主合同 常用修改一些 主子表 共同的状态
export function updateContractAndAllContractFlowByContractId(data) {
  return request({
    url: '/ec/flow/updateContractAndAllContractFlowByContractId',
    method: 'put',
    data: data
  })
}

// 修改【全部】合同的签署截止时间
export function updateContractSignExpiryDateByContractId(data) {
  return request({
    url: '/ec/flow/updateContractSignExpiryDateByContractId',
    method: 'put',
    data: data
  })
}

// 拒签合同
export function updateContractReject(data) {
  return request({
    url: '/ec/flow/updateContractReject',
    method: 'put',
    data: data
  })
}

// 缓存拒签合同
export function insertCacheRefuseContract(flowId) {
  return request({
    url: '/ec/flow/insertCacheRefuseContract/'+flowId,
    method: 'put',
  })
}
// 查询拒签合同
export function getCacheRefuseContract(flowId) {
  if(!!flowId){
    return request({
      url: '/ec/flow/getCacheRefuseContract/'+flowId,
      method: 'get',
    })
  }
}

// 删除合同签署流程
export function delContractSignMine(id) {
  return request({
    url: '/ec/flow/' + id,
    method: 'delete'
  })
}
// 逻辑删除合同签署流程
export function deleteLogicalFlow(id) {
  return request({
    url: '/ec/flow/deleteLogical/' + id,
    method: 'delete'
  })
}

// 签署方信息设置 签署流程定义 查询
export function signFlowSet(businessTypeId) {
  return request({
    url: '/ec/flow/signFlowSet',
    method: 'get',
    params: {contractBusinessTypeId:businessTypeId}
  })
}

// 接收方经办人没盖章权限 进行转签
export function transferFlow(data) {
  return request({
    url: '/ec/flow/transferFlow',
    method: 'post',
    data: data
  })
}


// 根据模板id和合同相关信息回显模板信息
export function warrantTemplateAndContractInfo(query) {
  return request({
    url: '/ec/flow/warrantTemplateAndContractInfo',
    method: 'get',
    params: query
  })
}

// 删除首页任务
export function deleteIndexTask(id) {
  return request({
    url: '/ec/flow/deleteIndexTask/' + id,
    method: 'put'
  })
}

// 根据签署方flowI 查询签署短连接
export function getContractFlowShortUrl(flowId) {
  return request({
    url: '/ec/flow/getContractFlowShortUrl/'+flowId,
    method: 'get',
  })
}
